﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQuarters.WebQuarters.Utils;

namespace OpenQuarters.WebQuarters.Core
{
    [Serializable]
    public class ItemDefinition
    {
        public string type = "";
        public string json = "";

        public IItemListable Item
        {
            get
            {
                return (IItemListable)Utils.GeneralUtils.FromJSON(json, null, Utils.GeneralUtils.GetTypeByName(type));
            }
        }

        public ItemDefinition(IItemListable item)
        {
            this.type = item.GetType().FullName;
            this.json = item.ToJSON();
        }

        public ItemDefinition()
        {
        }
    }
}
